using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Effects;

namespace GraphMyCode.Controls.Shaders
{
	public class SmoothMagnify : ShaderEffect
	{
		public static DependencyProperty CenterProperty = DependencyProperty.Register("Center", typeof(Point),
																					  typeof(SmoothMagnify),
																					  new PropertyMetadata(new Point(),
																										   PixelShaderConstantCallback
																											(0)));

		public static DependencyProperty Inner_RadiusProperty = DependencyProperty.Register("Inner_Radius", typeof(double),
																							typeof(SmoothMagnify),
																							new PropertyMetadata(
																								new double(),
																								PixelShaderConstantCallback(2)));

		public static DependencyProperty InputProperty = RegisterPixelShaderSamplerProperty("Input", typeof(SmoothMagnify), 0);

		public static DependencyProperty MagnificationProperty = DependencyProperty.Register("Magnification", typeof(double),
																							 typeof(SmoothMagnify),
																							 new PropertyMetadata(
																								new double(),
																								PixelShaderConstantCallback(3)));

		public static DependencyProperty Outer_RadiusProperty = DependencyProperty.Register("Outer_Radius", typeof(double),
																							typeof(SmoothMagnify),
																							new PropertyMetadata(
																								new double(),
																								PixelShaderConstantCallback(4)));

		public SmoothMagnify()
		{

			Uri u = new Uri(@"/GraphMyCode.Controls;component/Shader/SmoothMagnify.ps", UriKind.Relative);
			PixelShader = new PixelShader() { UriSource = u };

			// Must initialize each DependencyProperty that's affliated with a shader register
			// Ensures the shader initializes to the proper default value.
			UpdateShaderValue(InputProperty);
			UpdateShaderValue(CenterProperty);
			UpdateShaderValue(Inner_RadiusProperty);
			UpdateShaderValue(MagnificationProperty);
			UpdateShaderValue(Outer_RadiusProperty);
		}

		public virtual Brush Input
		{
			get { return ((Brush)(GetValue(InputProperty))); }
			set { SetValue(InputProperty, value); }
		}

		public virtual Point Center
		{
			get { return ((Point)(GetValue(CenterProperty))); }
			set { SetValue(CenterProperty, value); }
		}

		public virtual double Inner_Radius
		{
			get { return ((double)(GetValue(Inner_RadiusProperty))); }
			set { SetValue(Inner_RadiusProperty, value); }
		}

		public virtual double Magnification
		{
			get { return ((double)(GetValue(MagnificationProperty))); }
			set { SetValue(MagnificationProperty, value); }
		}

		public virtual double Outer_Radius
		{
			get { return ((double)(GetValue(Outer_RadiusProperty))); }
			set { SetValue(Outer_RadiusProperty, value); }
		}
	}
}